<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-saleOrder-edit"
			th:object="${saleOrder}">
			<input id="orderId" name="orderId" type="hidden" th:field="*{orderId}" />
			<div class="form-group">
				<label class="col-sm-3 control-label ">订单编号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="saleorderno"
						id="saleorderno" th:field="*{saleorderno}" readonly />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">会员卡号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="vipId" id="vipId"
						th:field="*{vipId}" readonly>
				</div>
			</div>
		    <div class="form-group">
				<label class="col-sm-3 control-label ">原价：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="receivable"
						id="receivable" th:field="*{receivable}"/>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label ">折后价：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="total"
						id="total" th:field="*{total}"/>
				</div>
			</div>
			
			<div class="form-group">
			<input type="hidden" th:value="*{barberId}" id="barberIdVal">
				<label class="col-sm-3 control-label ">理发师：</label>
				<div class="col-sm-8">
					<select id="bname" name="barberId" >
					</select>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label">支付状态：</label>
				<input type="hidden" id="stateVal" th:value="*{payState}">
				<div class="col-sm-8">
					<select name="payState" id="payState"  class="form-control">					
						<option value="1">未支付</option>
						<option value="2">已支付</option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	
	<script type="text/javascript">
	     
	
		$("#form-saleOrder-edit").validate({
			rules:{
				receivable:{
					required:true,
					checkMoney:true
					
				},
				total:{
					required:true,
					checkMoney:true
					
				},
				
			},
			messages: {
		       
		    }
		});
		$.validator.addMethod("checkMoney",function(value,element,params){  
            var checkMoney = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;  
            return this.optional(element)||(checkMoney.test(value));  
        },"请输入正确的金钱格式");
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	 $.operate.save("/order/edit", $('#form-saleOrder-edit').serialize());
	        }
	    }
		BName();
		$("#payState option[value='"+$('#stateVal').val()+"']").attr("selected","selected");
        function BName(){
        	$.ajax({
                type: "post",
                url: "/order/selectBname",
                dataType: "json",
                success: function(res){
                    if (null != res) {
                       var html= '';
                        Object.keys(res).forEach(function(key){
                            html += '<option value="' + res[key].uid + '" label="'+ res[key].name+'"></option>';
                        });
                        $('#bname').html(html);
            
                        var Flag=$("#barberIdVal").val();
                        //根据值让option选中 
                            $("#bname option[value='"+Flag+"']").attr("selected","selected");
                            $('#bname').addClass("form-control")
                            
                 
                    }
                    }
             });
        }
	</script>
</body>
</html>
